<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>拖车申请</title>
<jsp:include page="../../import.jsp" flush="true" />
<jsp:include page="../assParking/assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<form id="trailCar">
				<div class="fieldset1 tabel_col clearFix">
					<div class="fieldBox col_50">
						<div class="label">申请人</div>
		                <div class="field">
		                    <span id="applyNm" name="applyNm">${applyNm}</span>
		                </div>
					</div>
		            <div class="fieldBox col_50">
						<div class="label">申请时间</div>
						<div class="field">
							<span id="applyDt" name="applyDt">${sysDate}</span>
						</div>
					</div>
					<!-- 基本信息 -->
					<div class="caption">
						<span class="title">基本信息</span>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">承租人</div>
						<div class="field">
							<span id="cstNm_1" name="cstNm_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">合同编号</div>
						<div class="field">
							<span id="contNo" name="contNo">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
		                <div class="label">支付表号</div>
		                <div class="field">
		                    <span id="paySchNo" name="paySchNo">&nbsp;</span>
		                </div>
		            </div>
		            <div class="fieldBox col_33">
						<div class="label">经销商</div>
						<div class="field">
							<span id="splNm" name="splNm">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">事业部</div>
						<div class="field">
							<span id="orgName_1" name="orgName_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">业务负责人</div>
						<div class="field" style="width: 100%;">
							<span id="cstMgrNm" name="cstMgrNm">&nbsp;</span>
						</div>
					</div>
					<!-- 设备信息 -->
					<div class="caption">
						<span class="title">设备信息</span>
					</div>
					<div class="fieldBox col_100">
						<div class="sqPanel">
							<div id="detailGrid">
								<!-- 设备信息列表显示块 -->
								<div id="ligergrid_equ" class="sq-grid"></div>
								<div style="text-align: left;line-height: 2.3em;">
									<font color="red">&nbsp;&nbsp;注意：请保存前选择GPS在线状态！</font>
								</div>
							</div>
						</div>
					</div>
					<!-- 逾期信息 -->
					<div class="caption">
						<span class="title">逾期信息</span>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">租赁周期</div>
						<div class="field">
							<span id="lsPd" name="lsPd">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">已还租金(元)</div>
						<div class="field">
							<span id="actualAmt" name="actualAmt">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
		                <div class="label">逾期租金(元)</div>
		                <div class="field">
		                    <span id="overdueAmt" name="overdueAmt">&nbsp;</span>
		                </div>
		            </div>
		            <div class="fieldBox col_33">
						<div class="label">逾期天数</div>
						<div class="field">
							<span id="overdueDay" name="overdueDay">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">罚息金额(元)</div>
						<div class="field">
							<span id="penaltyAmt" name="penaltyAmt">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">应还款金额(元)</div>
						<div class="field">
							<span id="payAmt" name="payAmt">&nbsp;</span>
						</div>
					</div>
					<!-- 借款信息holly START-->
					<div class="caption">
						<span class="title">借款信息</span>
					</div>
					<div class="fieldBox col_100">
						<div class="sqPanel">
							<div id="detailGrid">
								<!-- 借款信息列表显示块 -->
								<div id="ligergrid_fin" class="sq-grid"></div>
							</div>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label  requiredSymbol"  >剩余未核销金额合计(元)</div>
						<div class="field col_50"  >
							<span id="arAmts" name="arAmts"> </span>
						</div>
					</div>
					<!-- 借款信息holly END-->
					<!-- 拖车信息 -->
					<div class="caption">
						<span class="title">拖车信息</span>
					</div>
		            <div class="fieldBox col_100">
						<div class="label">拖车原因</div>
						<div class="field">
							<textarea name="backReason" id="backReason" rows="3" class="l-textarea" style="width:98%" value="" ></textarea>
						</div>
					</div>
					<!-- 上传附件 -->
					<div class="fieldBox col_100">
						<div class="label">附件上传</div>
						<div class="field">
							<jsp:include page="../assCommFilesUpload.jsp" flush="true" >
								<jsp:param name="filePath" value="ass"/>
							</jsp:include>
							<div id="fileUpload1" class="upfileBoxs"></div>
							<span class="sq-button sq-button-hasicon" id="btnUpload1" onclick="ajaxFileUploadImg('uploads1',1)">
								<i class="sqBtnIco_9"></i>上传
							</span>
						</div>
					</div>
					<!-- 附件显示 -->
					<div class="fieldBox col_100">
						<div style="width: 98%; margin-left: 1%;">
			            	<jsp:include page="../assCommFilesList.jsp" flush="true" ></jsp:include>
							<div id="ligergrid_file1" class="sq-grid"></div>
						</div>
					</div>
                    <%--新增拖车渠道管理 将拖车单位变成选择项 并带出对应的银行账户信息--%>
                    <div class="fieldBox col_33">
                        <div class="label">渠道备案省</div>
                        <div class="field">
                            <select name="recordPrCd" id="recordPrCd"  validate ="{required:true,select:true}" onchange="getChn();">
                                <option value=" " selected="selected" >--请选择--</option>
                                <c:forEach items="${provinceKVList }" var="province">
                                    <option value="${province.key }">${province.value }</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_50" >
                        <div class="label">拖车单位名称</div>
                        <div class="field">
                            <input name="chnId"  id="chnId" value="" placeholder="--请选择--"  onchange="getAcc();" ltype="combobox"  validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                            <%--<div class="combo_itemList_wrap"></div>--%>
                        </div>
                    </div>
					<%--<!-- 可编辑信息 -->--%>
					<%--<div class="fieldBox col_33">--%>
						<%--<div class="label">拖车单位名称</div>--%>
						<%--<div class="field">--%>
							<%--<input name="companyNm" id="companyNm" value="" type="text" class="ui-textbox" validate="">--%>
						<%--</div>--%>
					<%--</div>--%>
		            <div class="fieldBox col_33">
						<div class="label">预计拖回时间</div>
						<div class="field">
							<input name="backDt" id="backDt" type="text" class="ui-datepicker" value="" validate="">
						</div>
					</div>
					<%--<div class="fieldBox col_33">--%>
						<%--<div class="label"></div>--%>
						<%--<div class="field"></div>--%>
					<%--</div>--%>
					<div class="fieldBox col_66_auto">
						<div class="label">拖回保管城市</div>
						<div class="field">
							<jsp:include page="../../system/sysRegion/region.jsp" flush="true" >
								<jsp:param name="regionShowLvl" value="2"/>
							</jsp:include>
							<span class="requiredSymbol">*</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">停车场名称</div>
						<div class="field">
							<input name="parkNm" id="parkNm" data-value=" " placeholder="--请选择--" ltype="combobox" validate="{required:true}">
							<span class="requiredSymbol">*</span>
						</div>
					</div>
		            <div class="fieldBox col_66">
						<div class="label">停车场地址</div>
						<div class="field">
							<input name="parkAddress" id="parkAddress" value="" type="text" readonly class="ui-textbox" validate="{required:true}">
							<span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">优车资产管理员</div>
						<div class="field">
							<input name="assMgs" id="assMgs" data-value=" " placeholder="--请选择--" ltype="combobox" validate="{required:true}">
							<span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">拖车费用(元/辆)</div>
						<div class="field">
							<input name="backPrice" id="backPrice" value="" type="text" class="ui-textbox" validate="{number:true}" onchange="setBackAmt()">
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">拖车数量</div>
						<div class="field">
							<input name="backQty" id="backQty" value="1" type="text" class="ui-textbox" validate="{digits:true}" onchange="setBackAmt()">
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">拖车费合计(元)</div>
						<div class="field">
							<input name="backAmt" id="backAmt" value="" type="text" class="ui-textbox" readonly validate="{number:true}">
						</div>
					</div>
                    <div class="fieldBox col_33">
                        <div class="label">拖回方式</div>
                        <div class="field">
                            <select name="backWayCd" id="backWayCd" validate="{required:true, select:true}">
                                <option value=" " selected="selected" >--请选择--</option>
                                <c:forEach items="${backWayCd}" var="backWayCd">
                                    <option value="${backWayCd.key}">${backWayCd.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
					<!-- 可编辑信息 -->
					<div class="caption">
						<span class="title">收款信息</span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">收款方名称</div>
						<div class="field">
							<input name="payeeAccNm" id="payeeAccNm" value="" type="text" readonly class="ui-textbox" validate="" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">开户银行</div>
						<div class="field">
							<input name="payeeBankNm" id="payeeBankNm" value="" type="text" readonly class="ui-textbox" validate="" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">开户行行号</div>
						<div class="field">
							<input name="payeeBankNo" id="payeeBankNo" value="" type="text" readonly class="ui-textbox" validate="{required:true, digits:true}">
                            <span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">银行账号</div>
						<div class="field">
							<input name="payeeAccNo" id="payeeAccNo" value="" type="text" readonly class="ui-textbox" validate="{required:true, digits:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
					</div>
                    <div class="caption">
                        <span class="title">函件发送信息</span>
                    </div>
                    <div class="fieldBox col_100">
                        <div class="label">函件是否发送</div>
                        <div class="field">
                            <select name="isSendFile" id="isSendFile" onchange="showOrHideHj()">
                                <option value=" " selected="selected" >-请选择-</option>
                                <option value="1" >是</option>
                                <option value="0" >否</option>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_100 notSendReasonDiv Hide">
                        <div class="label">不发送原因</div>
                        <div class="field">
                            <textarea name="notSendReason" id="notSendReason" rows="2" class="l-textarea" style="width:98%" value="" ></textarea>
                        </div>
                    </div>
                    <div class="fieldBox col_33 expressNmDiv Hide">
                        <div class="label">快递承运公司</div>
                        <div class="field">
                            <select name="expressNm" id="expressNm" >
                                <option value=" " selected="selected" >-请选择-</option>
                                <c:forEach items="${expressNm}" var="expressNm">
                                    <option value="${expressNm.key}">${expressNm.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_33 expressNumDiv Hide">
                        <div class="label">快递单号</div>
                        <div class="field">
                            <input name="expressNum" id="expressNum" value="" type="text" class="ui-textbox" >
                        </div>
                    </div>
                    <div class="fieldBox col_33 rcvRelationshipDiv Hide">
                        <div class="label">接收人关系</div>
                        <div class="field">
                            <select name="rcvRelationship" id="rcvRelationship" >
                                <option value=" " selected="selected" >-请选择-</option>
                                <c:forEach items="${rcvRelationship }" var="rcvRelationship">
                                    <option value="${rcvRelationship.key}">${rcvRelationship.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_33 rcvNmDiv Hide">
                        <div class="label">收件人</div>
                        <div class="field">
                            <input name="rcvNm" id="rcvNm" value="" type="text" class="ui-textbox" >
                        </div>
                    </div>
                    <div class="fieldBox col_33 rcvTelDiv Hide">
                        <div class="label">收件人手机号</div>
                        <div class="field">
                            <input name="rcvTel" id="rcvTel" value="" type="text" class="ui-textbox" >
                        </div>
                    </div>
                    <div class="fieldBox col_33 rcvAddrDiv Hide">
                        <div class="label">收件地址</div>
                        <div class="field">
                            <input name="rcvAddr" id="rcvAddr" value="" type="text" class="ui-textbox" >
                        </div>
                    </div>
                    <!-- 上传附件 -->
                    <div class="fieldBox col_100 fileUpload2Div Hide">
                        <div class="label">附件上传</div>
                        <div class="field">
                            <div id="fileUpload2" class="upfileBoxs"></div>
                            <span class="sq-button sq-button-hasicon" id="btnUpload2" onclick="ajaxFileUploadImg('uploads2', 2)">
								<i class="sqBtnIco_9"></i>上传
							</span>
                        </div>
                    </div>
                    <!-- 附件显示 -->
                    <div class="fieldBox col_100 ligergrid_file2Div Hide">
                        <div style="width: 98%; margin-left: 1%;">
                            <div id="ligergrid_file2" class="sq-grid"></div>
                        </div>
                    </div>
					<!-- 隐藏支付表主键、支付表号 -->
	                <div class="fieldBox col_100" style="display:none;">
	                    <div class="field">
	                         <input name="paySchId" id="paySchId" type="text" class="ui-textbox" value="${paySchId}">
                             <input name="enabledPaySchId" id="enabledPaySchId" type="text" class="ui-textbox" value="${enabledPaySchId}">
                             <input name="enabledPaySchNo" id="enabledPaySchNo" type="text" class="ui-textbox" value="${enabledPaySchNo}">
	                         <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="${paySchNo}">
	                         <input name="tcMasterId" id="tcMasterId" type="text" class="ui-textbox" value="${tcMasterId}">
	                         <input name="tcDetailId" id="tcDetailId" type="text" class="ui-textbox" value="${tcDetailId}">
	                         <input name="prjPrdDtlId" id="prjPrdDtlId" type="text" class="ui-textbox" value="${prjPrdDtlId}">
	                         <!-- 以下参数为流程需要 -->
	                         <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${prjId}">
	                         <input name="businessType" id="businessType" type="text" class="ui-textbox" value="${businessType}">
	                         <input name="prjTypCd" id="prjTypCd" type="text" class="ui-textbox" value="${prjTypCd}">
	                         <input name="prjNm" id="prjNm" type="text" class="ui-textbox" value="${prjNm}">
	                         <input name="orgName" id="orgName" type="text" class="ui-textbox" value="${orgName}">
	                         <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
	                         <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm}">
	                    </div>
	                </div>
				</div>
				<div class="btnsBox">
					<span id="saveAssTrailCarBtn" class="sq-button sq-button-round" onclick="saveAssTrailCar()">保存</span>
					<span id="closeBtn" class="sq-button sq-button-round" onclick="Remove_navTab()">关闭</span>
				</div>
			</form>
		</div>
	</div>

    <script>
	    $(function() {
	    	$("#trailCar").ligerForm({
				validate: true
			});//初始化表单
	        initData();//初始化数据
	    });

	    function showOrHideHj() {
	        var isSendFile = $("#isSendFile").val();
	        if ("0" == isSendFile) {
                $(".notSendReasonDiv").removeClass('Hide');
                $(".fileUpload2Div").removeClass('Hide');
                $(".ligergrid_file2Div").removeClass('Hide');
                $(".expressNmDiv").addClass('Hide');
                $(".expressNumDiv").addClass('Hide');
                $(".rcvRelationshipDiv").addClass('Hide');
                $(".rcvNmDiv").addClass('Hide');
                $(".rcvTelDiv").addClass('Hide');
                $(".rcvAddrDiv").addClass('Hide');
            } else if ("1" == isSendFile) {
                $(".notSendReasonDiv").addClass('Hide');
                $(".fileUpload2Div").addClass('Hide');
                $(".ligergrid_file2Div").addClass('Hide');
                $(".expressNmDiv").removeClass('Hide');
                $(".expressNumDiv").removeClass('Hide');
                $(".rcvRelationshipDiv").removeClass('Hide');
                $(".rcvNmDiv").removeClass('Hide');
                $(".rcvTelDiv").removeClass('Hide');
                $(".rcvAddrDiv").removeClass('Hide');
            } else {
                $(".notSendReasonDiv").addClass('Hide');
                $(".fileUpload2Div").addClass('Hide');
                $(".ligergrid_file2Div").addClass('Hide');
                $(".expressNmDiv").addClass('Hide');
                $(".expressNumDiv").addClass('Hide');
                $(".rcvRelationshipDiv").addClass('Hide');
                $(".rcvNmDiv").addClass('Hide');
                $(".rcvTelDiv").addClass('Hide');
                $(".rcvAddrDiv").addClass('Hide');
            }
        }
	    
	    //初始化数据
	    function initData(){
	    	var paySchId = $("#enabledPaySchId").val();
	    	if(!paySchId)return;
	    	var wait_dialog= $.ligerDialog.SQalert({
	            content: LogUtils.LOG_CMM_LOADING,
	            SQ_type: "waitting",
	            onClose: function () {
	            }
	        });
	    	
	    	var _url = '<%=path%>/ass/assTrailCarD/getTrailCarApplyInfo.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{enabledPaySchId:paySchId, dataFlag:"1"},
	    		url: _url,
	    		success:function(msg){
	    			 wait_dialog.close();
	    			 if(msg.success == 1){
	    				 setData(msg.data);//设置数据
	    			 }else{
	    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	    			 }
	    		}
	    	});
	    }
	
	    //设置页面数据
	    function setData(data){
	    	//加载表单
	    	liger.get("trailCar");
	    	//加载设备信息
	    	initGrid_equ(data);
	    	//加载借款信息
	    	initGrid_fin( );
	    	//加载文件列表信息
	    	loadFilesLiger("tcsq", 1, $("#tcMasterId").val());
            loadFilesLiger("tcsq_hj", 2, $("#tcMasterId").val());
	    }
		
		//初始化列表
		function initGrid_equ(data){
			$("#ligergrid_equ").ligerGrid({
				data: data,
				columns:[
					{ display: '租赁物名称', name: 'prdNm', minWidth: 180, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = rowdata.prdNm;
							//设置基本信息显示
				 	    	$("#cstNm_1").html(rowdata.cstNm);
				 	    	$("#contNo").html(rowdata.contNo);
				 	    	$("#paySchNo").html(rowdata.paySchNo);
				 	    	$("#splNm").html(rowdata.splNm);
				 	    	$("#orgName_1").html(rowdata.orgName);
				 	    	$("#cstMgrNm").html(rowdata.cstMgrNm);
							//设置逾期信息
							$("#lsPd").html(rowdata.lsPd);
							$("#actualAmt").html(rowdata.actualAmt / 100);
				 	    	$("#overdueAmt").html(rowdata.overdueAmt / 100);
				 	    	$("#overdueDay").html(rowdata.overdueDay);
				 	    	$("#penaltyAmt").html(rowdata.penaltyAmt / 100);
							$("#payAmt").html(rowdata.payAmt / 100);
							return h;
						}},
					{ display: '型号', name: 'prdMdl', minWidth: 150 , enabledSort:true},
					{ display: '是否新车', name: 'isNew', width: 100 , enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '否';
							if(rowdata.isNew==1){
								h = '是';
							}
							return h;
						}},
					{ display: '<font color="red">GPS是否在线</font>', name: 'isOnline', width: 120, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '';
				 	    	h+='<select id="isOnline" name="isOnline">';
				 	    	h+='<option value="0" ';
				 	    	if(rowdata.isOnline==0){
				 	    		h+='selected';
				 	    	}
				 	    	h+='>否</option>';
				 	    	h+='<option value="1" ';
				 	    	if(rowdata.isOnline==1){
				 	    		h+='selected';
				 	    	}
				 	    	h+='>是</option></select>';
							return h;
						}},
					{ display: '使用期限(月)', name: 'usedPd', width: 100 , enabledSort:true},
					{ display: '单价', name: 'guidePc', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = 0;
			                h = rowdata.guidePc / 100;
							return h;
						}},
					{ display: '数量', name: 'prdQty', width: 100, enabledSort:true},
					{ display: '留购价', name: 'rsrvPc', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = 0;
			                h = rowdata.rsrvPc / 100;
							return h;
						}},
					//{ display: '买卖合同编号', name: 'salContNo', width: 100 , enabledSort:true},
					{ display: '车辆配置单', name: 'overdueAmt', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '';
							h+='<a href="javascript:showOp(';
			                h+="'"+rowdata.prjId+"'";
			                h+=",'"+rowdata.prjPrdId+"'";
			                h+=")\">查看</a>";
							return h;
						}}
				],
				usePager: false,//是否有分页便签
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				height:'100%',
				heightDiff:-2,
				isScroll: false,//是否有滚动条
				checkbox:false,//列表是否有选择框
				rownumbers:false//列表是否有行号
			});
			grid = liger.get("ligergrid_equ");
			//grid.setHeight(100);
			grid.options.isSingleCheck = true;//列表是否为单选
		}
		
		/* HOLLY START*/
		//初始化借款信息
		function initGrid_fin( ){
			var paySchId = $("#paySchId").val();
			$("#ligergrid_fin").ligerGrid({
				parms:{paySchId:paySchId},
                url: '<%=path%>/finpayschfee/finance/getPaySchFeeList.do',
                method : 'get',
				columns:[
					{ display: '序号', name: 'arAmt', width: 40 , enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							return rowindex+1;
						}},
					{ display: '借款类型', name: 'feeTypCdNm', width: 150, enabledSort:true },
					{ display: '借款金额(元)', name: 'feeAmt', width: 150, enabledSort:true,render:function (rowdata, rowindex, value, column){
                                return value/100;
					} },
					{ display: '实付金额(元)', name: 'feeAmt', width: 150 , enabledSort:true,render:function (rowdata, rowindex, value, column){
						return value/100;
					}},
					{ display: '已核销金额(元)', name: 'paidUpAmt', width: 150, enabledSort:true,render:function (rowdata, rowindex, value, column){
						return value/100;
					}},
					{ display: '实付时间', name: 'crtTm', width: 200, enabledSort:true,render: function (rowdata, rowindex, value, column) { 
						var dateStr = "";
						if(null != value){
							var date = new Date(value);
							dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
						}
						return dateStr;
						}},
					{ display: '付款单号', name: 'feeRem', width: 200, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h ="";
							if( rowdata.pNo != null){
				                h+='<a class="sq-button-hasicon" href="javascript:commShowFlow(';
				                h+="'"+rowdata.pinstId+"'";
				                h+=",'"+rowdata.audStsCd+"'";
				                h+=",'"+rowdata.dataId+"'";
				                h+=",'"+rowdata.formUrl+"'";
				                h+=")\"><i class='sqBtnIco_32'></i>"+rowdata.pNo+"</a>";
							}
							return h;
						}},
					{ display: '备注', name: 'feeRem', width: 200, enabledSort:true }
				],
				onAfterShowData :function (e){
					var rows=e.rows;
					var i=0;
					for ( var index in rows) {
						i+=rows[index].arAmt;
					}
					 $("#arAmts").text(i/100+" 元");
				},
				usePager: false,//是否有分页便签
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				height:'100%',
				heightDiff:-2,
				isScroll: false,//是否有滚动条
				checkbox:false,//列表是否有选择框
				rownumbers:false//列表是否有行号
			});
		}
		//显示流程：流程实例ID,状态,业务主键(拖车主表ID)
	    function commShowFlow(_pInstId, _audStsCd, _businessKey,_formUrl){
	    	if(StringUtils.isEmpty(_pInstId)){
	    		UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
	    		return;
	    	}
	    	var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
	    	Add_navTab('tab_ass_trail_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
	    }
		
	    /* HOLLY END*/
	    
		//加载拖回保管城市等信息
		$(function(){
			//选定城市后-级联出停车场名字
			$("#rgnCityCd").ligerComboBox({
				valueField: 'key',
				textField: 'value',
				//width:150,
				onChangeValue:function(value){
					if(value){
						initParkNmSelectData(value);
					}else{//清空停车场名称
						var parkNmSelectObj = liger.get("parkNm");
						parkNmSelectObj.clear();
						parkNmSelectObj.setData({});//置空下拉框数据
					}
				}
			});
			//初始化停车场名称
			$("#parkNm").ligerComboBox({
				valueField: 'key',
				textField: 'value',
				//width:150,
				onChangeValue:function(value){
					if(value){
						initAssMgsSelectData(value);
					}else{//清空停车场名称
						var assMgsSelectObj = liger.get("assMgs");
						assMgsSelectObj.clear();
						assMgsSelectObj.setData({});//置空下拉框数据
						$("#parkAddress").val();//清空停车场地址信息
					}
				}
			});
			//初始化资产管理员
			$("#assMgs").ligerComboBox({
				valueField: 'key',
				textField: 'value'
			});
		});
		
		//查询停车场名字
		function initParkNmSelectData(value){
			if(!$("#parkNm").length)return;
			var citySelectObj = liger.get("rgnCityCd");
			var _cityCd = citySelectObj.findValueByText(value);
			if(!_cityCd){//市为空
				return;
			}
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{
					provinceCd:getRgnProvCd(),
					cityCd:getRgnCityCd()
				},
				url: '<%=path%>/ass/assParking/getParkNmByRgnCd.do',
				success:function(msg){
					 if(msg.success == 1){
						 var parkNmSelectObj = liger.get("parkNm");
						 if(msg.data){
							 parkNmSelectObj.setData(msg.data);
						 }else{
							 parkNmSelectObj.clear();
							 parkNmSelectObj.setData({});//置空下拉框数据
						 }
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		}
		
		//查询停车场对应资产管理员信息
		function initAssMgsSelectData(value){
			if(!$("#assMgs").length)return;
			var parkNmSelectObj = liger.get("parkNm");
			var _parkId = parkNmSelectObj.findValueByText(value);
			if(!_parkId){//停车场ID为空
				return;
			}
			//查询资产管理员
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{parkId:_parkId},
				url: '<%=path%>/ass/assParking/getAssMgsByParkId.do',
				success:function(msg){
					 if(msg.success == 1){
						 var assMgsSelectObj = liger.get("assMgs");
						 if(msg.data){
							 assMgsSelectObj.setData(msg.data);
						 }else{
							 assMgsSelectObj.clear();
							 assMgsSelectObj.setData({});//置空下拉框数据
						 }
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
			//查询停车场地址
	    	$.ajax({
	    		type: 'get',
	    		dataType: 'json',
	    		data: {id:_parkId},
	    		url: '<%=path%>/ass/assParking/getById.do',
	    		success:function(msg){
	    			 if(msg.success == 1){
	    				 $("#parkAddress").val(msg.data.parkAddress);//设置数据
	    			 }else{
	    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
	    			 }
	    		}
	    	});
		}
		
		//获取下拉框选中值
		function getParkId(){ //停车场
			var parkNmSelectObj = liger.get("parkNm");
			var _parkId = parkNmSelectObj.getValue();
			return _parkId;
		}
		function getAssMgId(){ //资产管理员
			var assMgsSelectObj = liger.get("assMgs");
			var _assMgId = assMgsSelectObj.getValue();
			return _assMgId;
		}
		//保存文件
		function saveFile(pkId,info,fileIndex,flag){
			var docArray = JSON.stringify(getUploadResultParams(fileIndex));
	        var url = "<%=path%>/ass/assTrailCarD/uploadAttchment.do";
        	if(null == docArray){
        		//无要上传的文件-直接结束
        		top.$.ligerDialog.SQalert({content: info,SQ_type: "success"});
        		Remove_navTab();//关闭申请窗口
        	}else{
		        if(pkId){//拖车主表ID不为空执行
			        //赋值附件
			        var data = {
						"docArray":docArray,
						"pkId": pkId,
						"flag": flag
					};
					//请求
			        AjaxUtils.ajaxPost(url, data, function(msg){
			        	if(msg.success == 1){
							 top.$.ligerDialog.SQalert({content: info,SQ_type: "success"});
							 if(msg.data){
								 //清空上传文件缓存
								 clearUploadResultParams(fileIndex);
							 }
							 Remove_navTab();//关闭申请窗口
						 }else{
							 UIUtils.alertError(msg.info);
						 }
			        }, true);
		        }else{
		        	$.ligerDialog.SQalert({content: "业务主键为空-不能保存文件！",SQ_type: "error"});
		        }
        	}
		}
		
		//显示已上传但是未保存的文件列表
		function showFiles(data, index){
			var applyNm = $("#applyNm").html();
			var applyDt = $("#applyDt").html();
			var f_Grid = liger.get("ligergrid_file"+index);
			var uploadJOSN = data;
    		for (var i=0; i< uploadJOSN.length; i++){ 
        		//添加行-追加行
        		f_Grid.addRow({fileNm: uploadJOSN[i].fileNm, crtUsrRlNm: applyNm, crtTm: applyDt, doSthFlag: "1", ligerIndex: index});
    		}
		}

		function validateHanJian() {
            var isSendFile = $("#isSendFile").val();
            if (" " == isSendFile) {
                return "请选择函件是否发送";
            } else {
                if (isSendFile == "0") {
                    var notSendReason = $("#notSendReason").val();
                    if (!notSendReason) {
                        return "请填写不发送原因";
                    } else if (notSendReason.length >  100) {
                        return "字数限制100字以内";
                    }
                    var hanJianFile = liger.get("ligergrid_file2");
                    var row = hanJianFile.getRow(0);
                    if (!row) {
                        return "请填写上传OA特批截图";
                    }
                } else if (isSendFile == "1") {
                    var expressNm = $("#expressNm").val();
                    if (" " == expressNm) {
                        return "请选择快递承运公司";
                    }
                    var expressNum = $("#expressNum").val();
                    if (!expressNum) {
                        return "请填写快递单号";
                    }
                    var rcvRelationship = $("#rcvRelationship").val();
                    if (" " == rcvRelationship) {
                        return "请选择接收人关系";
                    }
                    var rcvNm = $("#rcvNm").val();
                    if (!rcvNm) {
                        return "请填写收件人";
                    }
                    var rcvTel = $("#rcvTel").val();
                    if (!rcvTel) {
                        return "请填写收件人手机号";
                    }
                    var rcvAddr = $("#rcvAddr").val();
                    if (!rcvAddr) {
                        return "请填写收件地址";
                    }
                }
            }
        }
		
		//保存拖车申请信息（拖车信息主表）
		function saveAssTrailCar(){
			var ligerForm = liger.get("trailCar");
			if (!ligerForm.valid()) {
				top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
				return false; //验证不通过，不执行以下代码
			}
			//判断保管城市是否为空
			if(!getRgnProvCd() || !getRgnCityCd()){
				top.$.ligerDialog.SQalert({content: "请选择拖回保管城市信息！",SQ_type: "warning"});
				return false;
			}
			//判断停车场是否为空
			if(!getParkId()){
				top.$.ligerDialog.SQalert({content: "请选择停车场信息！",SQ_type: "warning"});
				return false;
			}
			//判断资产管理员是否为空
			if(!getAssMgId()){
				top.$.ligerDialog.SQalert({content: "请选择资产管理员信息！",SQ_type: "warning"});
				return false;
			}
            var resultMsg = validateHanJian();
			if (resultMsg) {
                top.$.ligerDialog.error(resultMsg);
                return false;
            }
			$.ligerDialog.confirm('确定保存并发起流程吗?', function (flag) {
				if(flag == false)return;
			   //获取表单数据
				var data = ligerForm.getData();
				data["provinceCd"] = getRgnProvCd();
				data["cityCd"] = getRgnCityCd();
				data["parkId"] = getParkId();
				data["manageId"] = getAssMgId();
				data["isOnline"] = $("#isOnline").val();
				data["applyNm"] = $("#applyNm").html();
				data["applyDt"] = $("#applyDt").html();
                data["channelId"] = liger.get("chnId").selectedValue;
                data["companyNm"] = liger.get("chnId").selectedText;
                data["enabledPaySchId"] = $("#enabledPaySchId").val();
                data["enabledPaySchNo"] = $("#enabledPaySchNo").val();
				//新增拖车信息主表数据
				var wait_dialog = null;
				var url = '<%=path%>/ass/assTrailCarM/add.do';
				$.ajax({
					type: 'post',
					dataType: 'json',
					data: data,
					url: url,
					beforeSend: function(){
						wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
					},
					success:function(msg){
						wait_dialog.close();
						//返回的拖车信息主表ID不为空执行一下操作
						if(msg.success == 1 && null != msg.data){
							saveFile(msg.data,msg.info,1, "tcsq");//保存文件
                            saveFile(msg.data,msg.info,2, "tcsq_hj");//保存文件
						}else{
							top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
						}
					}
				});
		});
	}

	//选择省触发获取省对应渠道
    function getChn(){
        //var recordPrCd =liger.get("recordPrCd").selectedValue;
        var recordPrCd =$("#recordPrCd").val();
        if(!recordPrCd || recordPrCd==undefined){
            return;
        }
        var isVaildFlag = 'true';//有效标志
        $.ajax({
            url: '<%=path%>/ass/assTrailCarChannel/getChnByPrCd.do?recordPrCd='+recordPrCd+'&&isVaildFlag='+isVaildFlag,
            dataType:'json',
            success: function (res) {
                var chnId = liger.get('chnId');
                chnId.gridManager.loadData(res);
                chnId.clear();
            }
        });
    }

    var comboGrid_defaultValue2='${id}';//渠道ID？
    var comboGrid_defaultText2='${channelNm}';
    var isInit_setSearchComboVal2 = false;
    var COMBO_BANK = $("#chnId").ligerComboBox({
        width: 300,
        selectBoxWidth: 300,
        selectBoxHeight: 240,
        valueField: 'id',
        textField: 'channelNm',
        isMultiSelect: true,
        isSingleCheck: true,
        grid: getBankNoGridOptions(true),
        delayLoadGrid: false
    });

    function getBankNoGridOptions(checkbox){
        // var recordPrCd =liger.get("recordPrCd").selectedValue;
        var recordPrCd =$("#recordPrCd").val();
        var options = {
            columns: [
                { display: 'id', name: 'id', minWidth: 150,hide:true },
                { display: '渠道名称', name: 'channelNm', minWidth: 100 },
                { display: '渠道类型', name: 'channelTypeCdStr', minWidth: 100 },
            ],
            switchPageSizeApplyComboBox: false,
            //url: '<%=path%>/project/prjprdbscinfo/getSplBankAccNoBySplId.do?splId=splId&&audStsCd='+FlowConstant.FLOW_CHECK_STATE_PASS+'&&purpCd=1',
            method: 'get',
            data:null,
            dataAction: 'local',
            root:'rows',
            record:'total',
            pageSize: 10,
            usePagerOnLessPagesize: false,
            cssClass: "SMALL_grid",
            // checkbox: checkbox,
            isSingleCheck: true,
            frozen: false,
            isSelected: function (rowdata) {
                if (comboGrid_defaultValue2 == "") return false;
                var defaultItems = comboGrid_defaultValue2.split(";");
                if(!isInit_setSearchComboVal2) { //只在初始化时执行一次，在onAfterShowData后改变
                    for (var i = 0; i < defaultItems.length; i++) {
                        if(rowdata[COMBO_BANK.options.valueField] == defaultItems[i]) {
                            return true;
                        }
                    };
                };
                return false;
            },
            onAfterShowData: function (currentData) {
                if(!isInit_setSearchComboVal2) {
                    COMBO_BANK.setInputValue(comboGrid_defaultValue2, comboGrid_defaultText2, true);
                    isInit_setSearchComboVal2 = false;
                }
            }
        };
        return options;
    }

    //获取拖车渠道账户信息
    function getAcc(){
        var channelId = liger.get("chnId").selectedValue;
        if(channelId==undefined){
            return;
        }
        $.ajax({
            url: '<%=path%>/ass/assChnBankAcc/getByChannelId.do?channelId='+channelId,
            dataType:'json',
            success: function (res) {
                // var chnId = liger.get('chnId');
                // chnId.gridManager.loadData(res);
                // chnId.clear();
                if (res.success == 1) {
                    var payeeAccNm = liger.get('payeeAccNm');
                    payeeAccNm.setValue(res.data.accNm)//账户名称
                    var payeeBankNm = liger.get('payeeBankNm');
                    payeeBankNm.setValue(res.data.bkNm)//开户银行
                    var payeeBankNo = liger.get('payeeBankNo');
                    payeeBankNo.setValue(res.data.bkNo)//开户行行号
                    var payeeAccNo = liger.get('payeeAccNo');
                    payeeAccNo.setValue(res.data.accNo)//银行账号
                } else {
                    var payeeAccNm = liger.get('payeeAccNm');
                    payeeAccNm.setValue("")//账户名称
                    var payeeBankNm = liger.get('payeeBankNm');
                    payeeBankNm.setValue("")//开户银行
                    var payeeBankNo = liger.get('payeeBankNo');
                    payeeBankNo.setValue("")//开户行行号
                    var payeeAccNo = liger.get('payeeAccNo');
                    payeeAccNo.setValue("")//银行账号
                }
            }
        });
    }


		//自动计算拖车费用合计
		function setBackAmt(){
			var backPrice = $("#backPrice").val().replace(/[^\d\.-]/g, "");
			var backQty = $("#backQty").val().replace(/\D{1,100}/,"");
			var totalMoney = 0;
			$("#backPrice").val(backPrice);
			$("#backQty").val(backQty);
			if(backPrice!='' && backQty!=''){
				totalMoney = parseInt(backPrice) * parseInt(backQty);
			}
			$("#backAmt").val(totalMoney);
		}
		
		//车辆配置单
		function showOp(_prjId,_prjPrdId){
		    Add_navTab("corePrcBook"+_prjPrdId, "车辆配置单", '<%=path%>/audit/audStandingBook/toCorePrcBookAddPage.do?prjPrdId='+_prjPrdId+'&proIntId='+$("#proIntId").val()+'&projectId='+_prjId+'&isDetail='+1);
		}
    </script>
</body>
</html>